package edu.buaa.act.travel.m.tpdl;

import org.json.JSONException;
import org.json.JSONObject;


public class TrainActivity extends TransitActivity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final String TYPE = "train";
	private String startCity;
	private String endCity;
	private String trainNum;
	public String getStartCity() {
		return startCity;
	}
	public void setStartCity(String startCity) {
		this.startCity = startCity;
	}
	public String getEndCity() {
		return endCity;
	}
	public void setEndCity(String endCity) {
		this.endCity = endCity;
	}
	public String getTrainNum() {
		return trainNum;
	}
	public void setTrainNum(String trainNum) {
		this.trainNum = trainNum;
	}
	
	@Override
	protected JSONObject toJSONObject(){
		JSONObject o = super.toJSONObject();
		try {
			o.put("startCity", startCity);
			o.put("endCity", endCity);
			o.put("trainNum", trainNum);
			o.put("type", TYPE);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return o;
	}
	
	@Override 
	public void fromJSON(JSONObject j) throws JSONException{
		super.fromJSON(j);
		this.setStartCity(j.getString("startCity"));
		this.setEndCity(j.getString("endCity"));
		this.setTrainNum(j.getString("trainNum"));
	}
}
